<template>
	<view class="activeLine">
		<view class="all">
			<view class="ao">邹大哥</view>
			<view class="aoot">15872200711</view>
		</view>

		<view class="attbox">
			<input class="banter" type="text" value="" placeholder="请输入位置" v-model="address" />
			<input class="banter" type="text" value="" placeholder="请输入面积" v-model="area" />
			<input class="banter" style="display: none;" v-model="id" />
			<view class="box2">
				<view class="bold">
					<textarea auto-height placeholder="你的需求描述:" v-model="describe" />
					</view>
			</view>
		</view>
		
		<view class="box5" @click="login">
			立即提交
		</view>
	</view>
</template>

<script>
	import instance from "../../api/requset.js"	
	export default {
		components: {
			
		},
		data() {
			return {
				address:'',
				area:'',
				describe:'',
				id:'',
				userId:null
			};
		},
		onLoad() {
			var that = this
			uni.getStorage({
			    key: 'id',
			    success: function (res) {
			        console.log(res.data);
					that.userId = res.data
			    }
			});
		},
		methods: {
			login(){
				var serverUrl = instance.serverUrl
				uni.request({
				    url: serverUrl + '/index.php/api/Member/room_demand', //仅为示例，并非真实接口地址。
				    data: {
						userid:this.userId,
						address:this.address,
						area:this.area,
						describe:this.describe
				    },
				    success: (res) => {
						console.log(res)
				        if(res.data.code==0){
							uni.showToast({
								title: res.data.msg,
								duration: 2000,
								icon: 'none'
							});
						}else{
							uni.showToast({
								title: res.data.msg,
								duration: 2000,
								icon: 'none'
							});
						}
				    }
				});
				if(this.location == ''){
					uni.showToast({
					    title: '请输入位置',
					    duration: 2000,
						icon:'none'
					});
				}else if(this.area == ''){
					uni.showToast({
					    title: '请输入面积',
					    duration: 2000,
						icon:'none'
					});
				}else if(this.demand == ''){
					uni.showToast({
					    title: '请填写你的需求',
					    duration: 2000,
						icon:'none'
					});
				}else{
						uni.showToast({
						    title: '提交成功',
						    duration: 2000
					});
					setTimeout(function() {
					   uni.switchTab({
						url: './Home'
					   })
					}, 1000);
					
				}
			}
		}
	}
</script>

<style>
	page{
		width: 100%;
		height: 100%;
		background-color: #F4F4F4;
	}
	.all{
		width: 95%;
		height: 200rpx;
		background-color: #FFFFFF;
		margin-left: 2.5%;
		margin-top: 20rpx;
		border-radius: 20rpx;
	}
	.ao{
		border-bottom: #f4f4f4 5rpx solid;
	}
	.aoot,.ao{
		width: 90%;
		height: 100rpx;
		margin-left: 5%;
		line-height: 100rpx;
	}
	.attbox{
		width: 95%;
		height: 480rpx;
		border-radius: 20rpx;
		background-color: #FFFFFF;
		margin-left: 2.5%;
		margin-top: 20rpx;
	}
	.banter{
		width: 90%;
		height: 100rpx;
		margin-left:5%;
		border-bottom: 1rpx #F4F4F4 solid;
	}
	.bold{
		width: 89%;
		height: 180rpx;
		margin-left: 5%;
		position: relative;
		top: 20rpx;
		border-radius: 20rpx;
	}
	.box2{
		width: 90%;
		height: 200rpx;
		margin-left: 5%;
		margin-top: 30rpx;
		border-radius: 20rpx;
		background-color: #F4F4F4;
	}
	.juan{
		margin-top: -70rpx;
	}
	.box5{
		width: 80%;
		margin-left: 10%;
		margin-top: 100rpx;
		border-radius: 20rpx;
		height: 80rpx;
		text-align: center;
		color: #fff;
		line-height: 80rpx;
		font-size: 30rpx;
		background-color: #0958A9;
	}
</style>
